package com.gexiaobao.pigeon.ui.adapter

import android.widget.ImageView
import androidx.appcompat.widget.AppCompatImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.flyjingfish.openimagelib.OpenImage
import com.flyjingfish.openimagelib.enums.MediaType
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.BreedingPairList
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.databinding.ItemRearBinding

/**
 * @Author      : hxw
 * @Date        : 2024/9/12 16:21
 * @Describe    :
 */
class AdapterRear : BaseQuickAdapter<BreedingPairList, DataBindBaseViewHolder>(R.layout.item_rear) {
    override fun convert(holder: DataBindBaseViewHolder, item: BreedingPairList) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemRearBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val ivImage = holder.getView<AppCompatImageView>(R.id.ivImage)
        ImageLoaderManager.loadRoundImage(context, item.maleUrl, ivImage, 6)

        ivImage.setOnClickListener {
            OpenImage.with(context)
                .setClickImageView(ivImage)
                .setSrcImageViewScaleType(ImageView.ScaleType.CENTER_CROP, true)
                .setImageUrl(item.maleUrl, MediaType.IMAGE).show()
        }
    }
}